import {Injectable} from "@angular/core";
import {ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot} from "@angular/router";
import {Observable} from "rxjs/internal/Observable";
import {AuthService} from "../service/auth/auth.service";

@Injectable()
export class NavGuard implements CanActivate{

  constructor(private authService: AuthService){

  }

  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
    if(this.authService.token){
      return true;
    }else {
      return false;
    }
  }

}
